﻿/*@charset "UTF-8";*/
/*----------------------------------------------
for official portal index
$Id: Default.js, v1.0 2011/8/8 02:29:08 jf $
----------------------------------------------*/
var callTigger = true;

$(document).ready(function () {
    ResizeImg(); infoDeCode();
    goodContToggle(); slideDetail();
});

function goodContToggle() {
    var obj = "";
    var oldpos = "";
    $("a.goodlistopen").toggle(function () {
        obj = $("div.divListUp").eq($("a.goodlistopen").index(this));
        $(this).css("background", "url('../images/button2.png')");
        if (obj.siblings("div.divListUp").length == 0) {
            $("#mainpageer").hide();
            CallIframe($(".Bid").eq(obj.index()).text());
        }
        else {
            obj.siblings("div.divListUp").slideUp(500, function () {
                $("#mainpageer").hide();
                CallIframe($(".Bid").eq(obj.index()).text());
            });
        }
    }, function () {
        $("#salegc").slideUp("fast", function () {
            if (obj.siblings("div.divListUp").length != 0) {
                obj.siblings("div.divListUp").slideDown(500);
            }
        });
        $(this).css("background", "url('../images/button.png')");
        $("#mainpageer").show();
    });
};

function slideDetail() {
    var oldheight = 0;
    $(".showdetail").toggle(function () {
        var curindex = $(".showdetail").index(this);
        var animateobj = $(".divListUp").eq(curindex);
        var newheight = animateobj.height() + $(".new_detail_body").eq(curindex).height() + 20;
        oldheight = animateobj.height();
        $(".activediv > div > .new_body > .nDetail > .newTitle > a").click();
        animateobj.animate({ height: newheight }, 400, function () {
            $(this).addClass("activediv");
        });
    }, function () {
        var curindex = $(".showdetail").index(this);
        var animateobj = $(".divListUp").eq(curindex);
        animateobj.animate({ height: oldheight }, 400, function () {
            $(this).removeClass("activediv");
        });
    });
};

function CallIframe(Bid) {
    if (callTigger) {
        $(".loading").show();
        $("#salegc").attr("src", "iDefault.aspx?Bid=" + Bid);  //to do open iframe
        $("#salegc").load(function () {
            $(".loading").fadeOut(function () {
                $("#salegc").css("display", "block");
                $("#salegc").height($("#salegc").contents().height() < 300 ? 300 : $("#salegc").contents().height());
                $("#salegc").fadeIn("fast");
                callTigger = false;
            });
        })
    }
    else {
        $("#salegc").fadeIn();
    }
};
function ResizeIframe() {
    $("#salegc").height($("#salegc").contents().height() < 300 ? 300 : $("#salegc").contents().height());
};